//
//  BBApplyViewController.m
//  BearSiX
//
//  Created by BearBaby on 16/3/25.
//  Copyright © 2016年 Tom. All rights reserved.
//

#import "BBApplyViewController.h"
#import "BBMyApplyViewController.h"
#import "BBMyApproveViewController.h"
@interface BBApplyViewController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView* tableView;
@property(nonatomic,strong)NSArray* list1;
@property(nonatomic,strong)NSArray* list2;
@property(nonatomic,strong)NSArray* images;
@property(nonatomic,strong)BBMyApplyViewController* myApplyVC;    //我的申请流程
@property(nonatomic,strong)BBMyApproveViewController* myApproveVC; //我的审批流程
@end

@implementation BBApplyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"申请";
    self.list1 = @[@"我的申请流程",@"我的审批流程"];
    self.list2 = @[@"请假、加班等，各种申请",@"需要我审批的事情"];
    self.images = @[@"00申请首页_03.png",@"00申请首页_07.png"];
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 2;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString* identifire = @"Cell";
    UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:identifire];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifire];
    }
    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[self.images objectAtIndex:indexPath.row]]];
    CGSize itemSize = CGSizeMake(50, 50);
    UIGraphicsBeginImageContext(itemSize);
    CGRect imageRect = CGRectMake(0, 0, itemSize.width, itemSize.height);
    [cell.imageView.image drawInRect:imageRect];
    cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndPDFContext();
    
    cell.textLabel.text = [self.list1 objectAtIndex:indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/22];
    cell.detailTextLabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1];
    cell.detailTextLabel.text = [self.list2 objectAtIndex:indexPath.row];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:WINSIZEWIDTH/27];
    cell.detailTextLabel.textColor = [UIColor colorWithRed:166/255.0 green:166/255.0 blue:166/255.0 alpha:1];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.userInteractionEnabled = YES;
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   
    if (indexPath.row==0) {
        self.myApplyVC = [[BBMyApplyViewController alloc]init];
        [self.navigationController pushViewController:self.myApplyVC animated:YES];
    }else if(indexPath.row==1){
        self.myApproveVC = [[BBMyApproveViewController alloc]init];
        [self.navigationController pushViewController:self.myApproveVC animated:YES];
    }


}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 66;

}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 15;

}

@end
